home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Editors / Emacs / Source / EmacsApp.m < prev    next >
Encoding:
Text File  |  1992-11-30  |  2.7 KB  |  117 lines

  1. /* The Application implementation for Emacs.
  2.  
  3.    For legal stuff see the file COPYRIGHT.  */
  4.  
  5. #import "EmacsApp.h"
  6.  
  7. @implementation EmacsApp
  8.  
  9. /* We're ready to start.  Size the window apropriately and fire up the emacs
  10.    process, possibly editing a file.  */
  11. -appDidInit: sender
  12. {
  13.   id window;
  14.  
  15.   DPSSetDeadKeysEnabled (DPSGetCurrentContext (), NO);
  16.  
  17.   window = [currentView window];
  18.   [window setBackgroundGray: NX_WHITE];
  19.   [window removeFromEventMask: NX_KEYUPMASK | NX_FLAGSCHANGEDMASK];
  20.   [window makeFirstResponder: currentView];
  21.   [window setFrameUsingName: "main"];
  22.   [window setFrameAutosaveName: "main"];
  23.  
  24.   [currentView startEmacs: files : nfiles];
  25.  
  26.   if (!strcmp (NXGetDefaultValue ([NXApp appName], "NXAutoLaunch"), "YES")
  27.       && !strcmp (NXGetDefaultValue ([NXApp appName],
  28.                      "HideOnAutoLaunch"), "YES"))
  29.     [self hide: self];
  30.   else
  31.     [self appDidUnhide: self];
  32.   [self setDelegate: self];
  33.   return self;
  34. } /* -appDidInit: */
  35.  
  36. -appDidUnhide: sender
  37. {
  38. #if 0
  39.   int eventChannel;
  40.  
  41.   evenChannel = [currentView eventChannel];
  42.   if (eventChannel)
  43.     fprintf (eventChannel, "(redraw-display)\n");
  44. #endif
  45.   [[currentView window] makeKeyAndOrderFront: self];
  46.   return self;
  47. } /* -appDidUnhide */
  48.  
  49. /* Intercept the Quit command and replace it with C-x C-c.  */
  50. -terminate: sender
  51. {
  52.   if (sender && [currentView quitEmacs])
  53.     return self;
  54.   return [super terminate: sender];
  55. } /* -terminate: */
  56.  
  57. -(BOOL) appAcceptsAnotherFile: sender
  58. {
  59.   return YES;
  60. } /* appAcceptsAnotherFile: */
  61.  
  62. /* Stash the name of a file in an instance variable so we can give it to the
  63.    child emacs when we fire it up.  */
  64. -(BOOL) app: sender openFile: (const char *) path type: (const char *) type
  65. {
  66.   if ([currentView emacsOn])
  67.     {
  68.       /* If emacs was already running, open file in a new buffer.  */
  69.       return [currentView newFile: path];
  70.     }
  71.   else
  72.     {
  73.       files = realloc (files, (nfiles + 1) * sizeof (char *));
  74.       files[nfiles++] = strcpy (malloc (1 + strlen (path)), path);
  75.     }
  76.   return YES;
  77. } /* -app:openFile:type: */
  78.  
  79. -currentView
  80. {
  81.   return currentView;
  82. } /* -currentView */
  83.  
  84. -fontManager
  85. {
  86.   if (!fontManager)
  87.     {
  88.       fontManager = [FontManager new];
  89.       [fontManager setDelegate: self];
  90.     }
  91.   return fontManager;
  92. } /* -fontManager */
  93.  
  94. -showFontPanel: sender
  95. {
  96.   [[NXApp fontManager] orderFrontFontPanel: self];
  97.   [fontManager setSelFont: [currentView font] isMultiple: NO];
  98.   return self;
  99. } /* -showFontPanel: */
  100.  
  101. -(BOOL) fontManager: sender willIncludeFont: (const char *) fontName
  102. {
  103.   NXFontMetrics *metrics;
  104.   id font;
  105.  
  106.   font = [Font newFont: fontName size: (float) 10];
  107.   if (font != nil)
  108.     {
  109.       metrics = [font readMetrics: NX_FONTHEADER];
  110.       if (metrics != NULL)
  111.     return metrics->isFixedPitch;
  112.     }
  113.   return NO;
  114. } /* fontManager:willIncludeFont: */
  115.  
  116. @end
  117.